<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企业微信管理后台</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../css/reset.css">
    <link rel="stylesheet" href="../../css/main.css">
</head>

<body>
    <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    <div id="cus_contact">
        <div class="left_wrapper">
            <!-- 2020-02-24 start -->
            <ul class="left_nav">
                <li class="nav_item active">
                    <span data-url="contact-cus-kpi-1.html">联系客户统计</span>
                </li>
                <li class="nav_item">
                    <span data-url="contact-cusgroup-kpi-1.html">联系客户群统计</span>
                </li>
                <li class="nav_item">
                    <span data-url="customer-setgroup-statistics.html">客户建群统计</span>
                </li>
                <li class="nav_item">
                    <span data-url="customer.html">客户统计</span>
                </li>
            </ul>
            <!-- 2020-02-24 end -->
        </div>
        <div class="right_wrapper">
            <iframe class="right_iframe" id="right_iframe" src="customer.html" frameborder="0"
                allowtransparency="true"></iframe>
        </div>
    </div>
    <script src="../../js/jquery-3.3.1.min.js"></script>
    <script>
        // function setIframeHeight(iframe) {
        //     if (iframe) {
        //         var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
        //         if (iframeWin.document.body) {
        //             iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
        //         }
        //     }
        // };

        // window.onload = function () {
        //     setIframeHeight(document.getElementById('right_iframe'));
        // };

        function reinitIframe() {
            var iframe = document.getElementById("right_iframe");
            try {
                var bHeight = iframe.contentWindow.document.body.scrollHeight;
                var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                var height = Math.max(bHeight, dHeight);
                iframe.height = height;
            } catch (ex) { }
        }
        window.setInterval("reinitIframe()", 1000);

        // 2020-02-20 start
        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
        let nav_index = 0;
        if (getUrlParam('nav_index')) {
            nav_index = getUrlParam('nav_index')
        }
        $(".left_nav .nav_item").eq(nav_index).addClass('active').siblings().removeClass('active');
        let nowRightUrl = $(".left_nav .nav_item").eq(nav_index).find('span').attr('data-url');
        $("#right_iframe").attr('src', nowRightUrl)
        // 2020-02-20 end

        // nav点击
        $('.left_nav').on('click', '.nav_item', function () {
            let url = $(this).children('span').attr('data-url')
            $(this).addClass('active').siblings().removeClass('active')
            $("#right_iframe").attr('src', url)
        })
    </script>
</body>

</html>